package jdsk.iria;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;

public class AnalysisActivity extends Activity {

	private static String studentName;
	private static String fileName;
	private static String teacherName;
	private static String CB;
	private static CheckBox checkbox1;
	private static CheckBox checkbox2;
	private static CheckBox checkbox3;
	private int countOfGestures;
	private int numOfWords;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_analysis);

		checkbox1 = (CheckBox) findViewById(R.id.checkBox1);
		checkbox2 = (CheckBox) findViewById(R.id.checkBox2);
		checkbox3 = (CheckBox) findViewById(R.id.checkBox3);

		checkbox1.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				checkbox2.setChecked(false);
				checkbox3.setChecked(false);
				CB = (String) checkbox1.getText();
			}
		});
		checkbox2.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				checkbox1.setChecked(false);
				checkbox3.setChecked(false);
				CB = (String) checkbox2.getText();
			}
		});

		checkbox3.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				checkbox1.setChecked(false);
				checkbox2.setChecked(false);
				CB = checkbox3.getText().toString();
			}
		});

		Bundle extras = getIntent().getExtras();
		if (extras != null) {
			studentName = extras.getString("studentName");
			teacherName = extras.getString("teacherName");
			fileName = extras.getString("fileName");
			countOfGestures = extras.getInt("countOfGestures");
			numOfWords = extras.getInt("numOfWords");
		}

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_analysis, menu);
		return true;
	}

	/**
	 * handles the save button being clicked
	 * @param view
	 */
	public void saveAnalysisButtonClick(View view) {

		final CheckBox check1 = (CheckBox) findViewById(R.id.checkBox1);
		if (check1.isChecked()) {

		}

		Bundle dataBundle = new Bundle();
		dataBundle.putString("notes", ((EditText) findViewById(R.id.editText1))
				.getText().toString());
		dataBundle.putString("fileName", fileName);
		dataBundle.putString("studentName", studentName);
		dataBundle.putString("teacherName", teacherName);
		dataBundle.putString("CB", CB);
		dataBundle.putInt("countOfGestures", countOfGestures);
		dataBundle.putInt("numOfWords", numOfWords);
		Intent myIntent = new Intent(this, FluencyActivity.class);
		myIntent.putExtras(dataBundle);
		this.startActivity(myIntent);

	}

}
